package structure;

public class Stack {
	
	private static final int maxSize = 30;
	int[] Data = new int[maxSize];
	int top;
	
	public Stack() {
		this.top = -1;
	}
	
	/*
	 * @param 要Push进堆栈的元素
	 * 向堆栈中压入元素
	 */
	public void Push(int item) {
		if(this.isFull()) {
			System.out.println("堆栈已满");
			return;
		}else {
			this.Data[++(this.top)] = item;
			return;
		}
	}
	/*
	 * @return 堆顶的元素
	 * 从堆栈中抛出元素
	 */
	public int Pop() {
		if(this.isEmpty()) {
			System.out.println("堆栈为空");
			return Integer.MAX_VALUE;
		}else {
			return (this.Data[(this.top)--]);
		}
	}
	
	public boolean isEmpty() {
		if(this.top == -1) {
			return true;
		}else {
			return false;
		}
	}
	
	public boolean isFull() {
		if(this.top == maxSize - 1) {
			return true;
		}else {
			return false;
		}
	}
}
